package com.threeti.mecool.web.controller;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.UUID;

import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * 测分页效果
 * @author Yuqi Chou 
 * @version May 26, 2012  10:32:30 AM
 */
@Controller
public class TestPageController {
	
	List<String> db=new ArrayList<String>();
	
	public TestPageController() {
		for (int i = 0; i < 35; i++) {
			db.add(UUID.randomUUID().toString().substring(0, 4));
		}
	}
	
	
	@RequestMapping(value = "/userListData.html", method = RequestMethod.GET)
	public String test(@RequestParam(defaultValue = "1", required = false) int gotopage,
					   @RequestParam(defaultValue = "20", required = false) int pagesize,
					   HttpServletRequest request,
					   Map modelMap) {
		
		try {
			Thread.currentThread().sleep(1500);
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
		Page p=new Page(gotopage, db.size(), pagesize);
		p.setData(db.subList(gotopage, gotopage+pagesize));
		modelMap.put("page", p);
		modelMap.put("requestUrl", request.getRequestURI());
		return "/admin/userListData";
	}
	
	
}
